package com.scheuk.euler;

import java.util.BitSet;

public class p007 {

	
	public static int getNthPrime(int nth)
	{
		int counter = 0;
		int limit = 10000000;
		BitSet bs = MathTools.computePrimes(limit);
		for (int i = 0; i < limit; i++)
		{
			if(bs.get(i)) counter++;
			if (counter == nth) return i;
		}
		return -1;
	}
	
	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		System.out.println("time: " + ((System.currentTimeMillis() - start)/1000) + " s");
		System.out.println("answer: " + p007.getNthPrime(10001));
	}
}
